from tools.treeNode import Tree


def invertTree(root):
    if root:
        root.left, root.right = root.right, root.left
        if root.left:
            invertTree(root.left)
        if root.right:
            invertTree(root.right)
    return root


root = Tree(1)
root.left = Tree(2)
root.right = Tree(3)
root.left.left = Tree(4)
root.left.right = Tree(5)
root.right.left = Tree(6)
root.right.right = Tree(7)
invertTree(root)

print(root.val)
print(root.left.val)
print(root.right.val)
print(root.left.left.val)
print(root.left.right.val)
print(root.right.left.val)
print(root.right.right.val)
